from django.db import models
from django.contrib.sites.models import Site
from django.core.exceptions import ObjectDoesNotExist
from cmsdj import settings

class SiteCfg (models.Model):
    title = models.CharField ( max_length = 256 )
    subtitle = models.CharField ( max_length = 256 , blank=True, null=True)
    abstract = models.TextField ( blank=True, null=True )
    footinfo = models.TextField ( blank=True, null=True )
    site = models.OneToOneField(Site) #ForeignKey(Site, default = Site.objects.get_current(), blank = True, null = True)
    template = models.CharField ( max_length = 256 , blank=True, null=True, default='default')

    @staticmethod
    def current_cfg():
        try:
            return SiteCfg.objects.get(site = Site.objects.get_current().id)
        except ObjectDoesNotExist:
            return SiteCfg()
